﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Model;
using Dal;
using System.Data;

namespace Bll
{
    public class BllProfessional
    {
        DalProfessional d = new DalProfessional();

        public DataTable Nav_Inquire_All()
        {
            //一级导航全部信息
            return d.Nav_Inquire_All();
        }//一级导航全部信息

        public DataTable SubNav_Inquire_All(ModelPublic m)
        {
            //二级导航全部信息
            return d.SubNav_Inquire_All(m);
        }//二级导航全部信息\
        
        public string Professional_Id(ModelPublic m)
        {
            //信息编号
            return d.Professional_Id(m);
        }//信息编号

        public DataTable Professional_Search_All(ModelPublic m)
        {
            //检索信息(发布版)
            return d.Professional_Search_All(m);
        }//检索信息(发布版)
        
        public DataTable Professional_Search_Unpublished(ModelPublic m)
        {
            //检索信息(未发布版)
            return d.Professional_Search_Unpublished(m);
        }//检索信息(未发布版)

        public bool Professional_Delete(ModelPublic m)
        {
            //信息删除
            return d.Professional_Delete(m);
        }//信息删除

        public DataTable Professional_Inquire_All(ModelPublic m)
        {
            //获取全部信息(发布版)
            return d.Professional_Inquire_All(m);
        }//获取全部信息(发布版)

        public DataTable Professional_Inquire_All_Unpublished(ModelPublic m)
        {
            //获取全部信息(未发布版)
            return d.Professional_Inquire_All_Unpublished(m);
        }//获取全部信息(未发布版)

        public DataTable Professional_Inquire_Single(ModelPublic m)
        {
            //查询单条信息
            return d.Professional_Inquire_Single(m);
        }//查询单条信息

        public string Professional_Modify(ModelPublic m)
        {
            //专业信息修改
            if (d.Professional_Modify(m))
                return "1";
            else
                return "修改失败！";
        }//专业信息修改

        public string Professional_Add(ModelPublic m)
        {
            //信息添加
            if (m.NavSubId == "0")
            {
                return "请选择专业类型！";
            }
            if (m.Title == "")
            {
                return "请输入新闻标题！";
            }
            if (m.Author == "")
            {
                return "请输入新闻作者";
            }
            if (m.DateTime == "")
            {
                return "请输入发布时间！";
            }
            if (m.Content == "")
            {
                return "请输入新闻内容！";
            }

            if (!d.Professional_Is(m))
            {
                if (d.Professional_Add(m))
                    return "1";
                else
                    return "添加失败！";
            }
            else
                return "专业已存在！";
        }//信息添加
    }
}
